<div class="index">

		<div class="center">
			<left></left>
			<div class="right">
          <top></top>
          <div class="hei10"></div>
          <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">当前位置：分销后台>
          <router-link to="/myDistributor" style="color: #409eff;">我的分销商</router-link>
          >编辑佣金
          </div>
          <div class="hei10"></div>

				<div class="title">编辑分销商佣金</div>
				<div class="add">
					<el-input placeholder="分销商店铺名" v-model="search" class="input-with-select"></el-input>
					<el-button type="primary" @click="searchgo" icon="el-icon-search"></el-button>
				</div>
				<div class="con" v-loading="loading">
					<div class="list">
						<div class="th">分销商店铺</div>
						<div class="th">佣金</div>
					</div>
					<div class="listl">
						<div class="list" v-for="item in list" :key="item.id">
							<div class="td">{{item.title}}</div>
							<div class="td"><el-input v-model="item.commission" @input="fixmoney(item.id,item.commission)" placeholder="佣金"></el-input></div>
						</div>
					</div>
					<!-- <el-pagination background layout="prev, pager, next" :page-size="20" :total="total"></el-pagination> -->
				</div>
			</div>
		</div>
		<el-dialog title="编辑佣金" :visible.sync="log" width="440px">
			  <div>
				  <el-input v-model="money" placeholder="请输入佣金金额"></el-input>
			  </div>
			  <span slot="footer" class="dialog-footer">
				<el-button @click="log = false">取消</el-button>
				<el-button type="primary" @click="log = false">保存</el-button>
			  </span>
		</el-dialog>

	</div>
</template>

<script>
	import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	export default{
		components: {
			"left": left,
			"top": top
		},
		name: 'editMoney',
		data(){
			return{
				loading:true,
				search:"",
				log:false,
				money:"",
				total:0,
				list:""
			}
		},
		created() {
			this.getlist();
		},
		methods:{
			//编辑佣金
			fixmoney:function(id,commission){
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id",id);
				formData.append("child_shop_id",this.$route.query.id);
				formData.append("commission",commission);

				axios.post('/api/plan-market/order-page/commissions/update',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							// this.getmoneylist();
							// that.$message({
							//   message: '保存成功！',
							//   type: 'success'
							// });
						}else{
							if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//获取
			getlist:function(){
                this.search = this.search.trim()
				var that = this;
				axios.get('/api/plan-market/partner/products/commissions?child_shop_id='+this.$route.query.id+'&name='+encodeURIComponent(this.search))
					.then(response => {
						if(response.data.msg.code == 0){
							that.list = response.data.data.data
							that.total = response.data.total
							that.loading = false
						}else{
							if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//搜索
			searchgo:function(){
				this.loading = true
				this.getlist()
			},

		}

	}
</script>

<style lang="scss" scoped>
	.index{
				.title{border-bottom: 1px #EAEAEA solid;  line-height: 45px; padding-left: 30px; font-size: 16px; background: #F9F9F9; color: #727272;}
				.add{
					padding: 20px 30px; text-align: right; position: relative;
					.input-with-select{ width: 280px;}
					.el-button{ position: absolute; right: 30px; top: 20px; padding: 10px 20px;}
				}
				.listl{
					.el-input__inner{ border: none !important; text-align: center}
				}
				.list{
					display: flex; text-align: center; color: #727272; line-height: 45px; border: 1px #EAEAEA solid; margin-top: -1px;
					.th{ flex: 1; background: #F9F9F9; font-size: 14px; border-right:1px #EAEAEA solid;  }
					.td{ flex: 1; font-size: 14px; border-right:1px #EAEAEA solid; }

				}
				.el-pagination{ text-align: right; margin: 20px 0}
				.my{
					display: flex; justify-content: space-between; padding: 20px; line-height: 20px;
					.myid{
						font-size: 17px; color: #DD2727; padding-left: 10px;
						span{ color: #B1B1B1; font-size: 14px; margin-left: 20px}
					}
					.invitation{
						font-size: 14px; color: #B1B1B1;
						span{ color: #197CFF; cursor: pointer;}
					}
				}
	}
</style>
